<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>BatteryCharger: charger.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">BatteryCharger
   &#160;<span id="projectnumber">5.0</span>
   </div>
   <div id="projectbrief">A smart charger for lead-acid batteries.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('charger_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">charger.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="charger_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#ifndef _CHARGER_H_</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define _CHARGER_H_</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="charger_8h.html#af7c58a614424d78e44e2b6d844959346">   36</a></span>&#160;<span class="preprocessor">#  define SAMPLES_FAST_AVERAGE 64</span></div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="charger_8h.html#ab78b5dd637d266b4c3f5642da81ba69e">   37</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define SAMPLES_TO_AVERAGE 512</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="charger_8h.html#a236e185c458da8c4305d3bb63fa98df6">   51</a></span>&#160;<span class="preprocessor">#  define V_SCALE_NUMERATOR   5000</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="charger_8h.html#a00636604332cb667db002f53b69bd1ec">   52</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define V_SCALE_DENOMINATOR 1000</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="charger_8h.html#a50c835c628316f78a55515a58589e3c2">   53</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define V_MAX_MV ((ADC_VREF_MV*V_SCALE_NUMERATOR)/V_SCALE_DENOMINATOR)</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="charger_8h.html#af8388d9a82ee5d20fc2d73121ccdb865">   67</a></span>&#160;<span class="preprocessor">#  define I_SCALE_NUMERATOR   1000</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"><a class="line" href="charger_8h.html#a6694bd50b6bb606f9bee605d7aa44fe1">   68</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define I_SCALE_DENOMINATOR 1000</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="charger_8h.html#a4664d8f2c7b5fc7c1619a86f0ec4b22d">   69</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define I_MAX_MA ((ADC_VREF_MV*I_SCALE_NUMERATOR)/I_SCALE_DENOMINATOR)</span></div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="charger_8h.html#a155b9d569ca9278041cbc9692ef10107">   82</a></span>&#160;<span class="preprocessor">#  define SHORT_VOLTAGE_MV 11000</span></div>
<div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="charger_8h.html#a6dc1bd0a4ebfb54241782dc63ac3ec9b">   83</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define OPEN_VOLTAGE_MV  15000</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00093"></a><span class="lineno"><a class="line" href="charger_8h.html#acc1654433c4c1af7ad32859fc0ebb318">   93</a></span>&#160;<span class="preprocessor">#  define MODE1_VOLTAGE_MV 14400</span></div>
<div class="line"><a name="l00094"></a><span class="lineno"><a class="line" href="charger_8h.html#a75719826231baaded30955287d81da29">   94</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define MODE1_CURRENT_MA 1800</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="charger_8h.html#a3dbda1866df5cd0bc16fab99924bdb5d">  104</a></span>&#160;<span class="preprocessor">#  define MODE2_VOLTAGE_MV   14400</span></div>
<div class="line"><a name="l00105"></a><span class="lineno"><a class="line" href="charger_8h.html#a9fac06211d62c1a2967d00a6e50c54c1">  105</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define MODE2_CURRENT_MA   100</span></div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="charger_8h.html#a653480f2af346947a14055dbddb464f5">  113</a></span>&#160;<span class="preprocessor">#  define MODE3_VOLTAGE_MV   12900</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="charger_8h.html#a1d5c9bdfffcd88931bcab5add8f69330">  124</a></span>&#160;<span class="preprocessor">#  define BTN1_PORT          LPC_GPIO1</span></div>
<div class="line"><a name="l00125"></a><span class="lineno"><a class="line" href="charger_8h.html#a0d2171fc428bb1690de2d6d35f11fae9">  125</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define BTN1_Pos           8</span></div>
<div class="line"><a name="l00126"></a><span class="lineno"><a class="line" href="charger_8h.html#a88d687ec0270b05e20c85c83f191a024">  126</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define BUTTON1_PRESSED    (~(BTN1_PORT-&gt;DATA) &amp; (1uL &lt;&lt; BTN1_Pos))</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00136"></a><span class="lineno"><a class="line" href="charger_8h.html#afc6a495708d126d07577bdd74cd693e9">  136</a></span>&#160;<span class="preprocessor">#  define FLAG1_PORT         LPC_GPIO1</span></div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="line" href="charger_8h.html#acedebf22a3c3cacb217471d48d37a8f5">  137</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define FLAG1_Pos          5</span></div>
<div class="line"><a name="l00138"></a><span class="lineno"><a class="line" href="charger_8h.html#adb0d94571d7ef7df43a94647c13a730a">  138</a></span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  define FLAG1_Msk          (1 &lt;&lt; FLAG1_Pos)</span></div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00142"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cde">  142</a></span>&#160;<span class="keyword">enum</span> <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cde">ChargerState</a> {</div>
<div class="line"><a name="l00146"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea2fd6f336d08340583bd620a7f5694c90">  146</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea2fd6f336d08340583bd620a7f5694c90">ERROR</a> = 0,</div>
<div class="line"><a name="l00150"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeaaab5a2bcea860b4f52557e01cb37c66f">  150</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeaaab5a2bcea860b4f52557e01cb37c66f">CALIBRATE</a>,</div>
<div class="line"><a name="l00155"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea84e04feeb70146c1d6f609660d20cea0">  155</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea84e04feeb70146c1d6f609660d20cea0">WAIT4BUTTON</a>,</div>
<div class="line"><a name="l00161"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeac53ee90175038245e571a7afe7985feb">  161</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeac53ee90175038245e571a7afe7985feb">CHECK4BATT</a>,</div>
<div class="line"><a name="l00166"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeacad1f95421284c28d462180d85c320e9">  166</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeacad1f95421284c28d462180d85c320e9">CC_CHARGE</a>,</div>
<div class="line"><a name="l00170"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea51ed40b70a4a73164180010de321e4a9">  170</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea51ed40b70a4a73164180010de321e4a9">CV_CHARGE</a>,</div>
<div class="line"><a name="l00174"></a><span class="lineno"><a class="line" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea50641d73493fcffb14b565b51a27d6f3">  174</a></span>&#160;  <a class="code" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea50641d73493fcffb14b565b51a27d6f3">TRICKLE</a></div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;};</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;</div>
<div class="line"><a name="l00177"></a><span class="lineno"><a class="line" href="charger_8h.html#ad81e98c190f340de41b9d2092d640cdd">  177</a></span>&#160;uint32_t <a class="code" href="charger_8h.html#ad81e98c190f340de41b9d2092d640cdd">State</a>;</div>
<div class="line"><a name="l00178"></a><span class="lineno"><a class="line" href="charger_8h.html#a83e89a22da06d138a4a9373955d02d34">  178</a></span>&#160;uint32_t <a class="code" href="charger_8h.html#a072b3046a3b425f96c26c3bb1a9376b8">FastVoltage</a>, <a class="code" href="charger_8h.html#a0142489055e8b3b737784a72afddf73b">RawCurrent</a>, <a class="code" href="charger_8h.html#a83e89a22da06d138a4a9373955d02d34">RawVoltage</a>;</div>
<div class="line"><a name="l00179"></a><span class="lineno"><a class="line" href="charger_8h.html#a3edd7bb06bb02480aecd235e8ae70219">  179</a></span>&#160;uint32_t <a class="code" href="charger_8h.html#a3edd7bb06bb02480aecd235e8ae70219">Temperature</a>;</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdeac53ee90175038245e571a7afe7985feb"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdeac53ee90175038245e571a7afe7985feb">CHECK4BATT</a></div><div class="ttdef"><b>Definition:</b> charger.h:161</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdea2fd6f336d08340583bd620a7f5694c90"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdea2fd6f336d08340583bd620a7f5694c90">ERROR</a></div><div class="ttdef"><b>Definition:</b> charger.h:146</div></div>
<div class="ttc" id="charger_8h_html_a3edd7bb06bb02480aecd235e8ae70219"><div class="ttname"><a href="charger_8h.html#a3edd7bb06bb02480aecd235e8ae70219">Temperature</a></div><div class="ttdeci">uint32_t Temperature</div><div class="ttdef"><b>Definition:</b> charger.h:179</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdeaaab5a2bcea860b4f52557e01cb37c66f"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdeaaab5a2bcea860b4f52557e01cb37c66f">CALIBRATE</a></div><div class="ttdef"><b>Definition:</b> charger.h:150</div></div>
<div class="ttc" id="charger_8h_html_a0142489055e8b3b737784a72afddf73b"><div class="ttname"><a href="charger_8h.html#a0142489055e8b3b737784a72afddf73b">RawCurrent</a></div><div class="ttdeci">uint32_t RawCurrent</div><div class="ttdef"><b>Definition:</b> charger.h:178</div></div>
<div class="ttc" id="charger_8h_html_ad81e98c190f340de41b9d2092d640cdd"><div class="ttname"><a href="charger_8h.html#ad81e98c190f340de41b9d2092d640cdd">State</a></div><div class="ttdeci">uint32_t State</div><div class="ttdef"><b>Definition:</b> charger.h:177</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdea84e04feeb70146c1d6f609660d20cea0"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdea84e04feeb70146c1d6f609660d20cea0">WAIT4BUTTON</a></div><div class="ttdef"><b>Definition:</b> charger.h:155</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdea50641d73493fcffb14b565b51a27d6f3"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdea50641d73493fcffb14b565b51a27d6f3">TRICKLE</a></div><div class="ttdef"><b>Definition:</b> charger.h:174</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdea51ed40b70a4a73164180010de321e4a9"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdea51ed40b70a4a73164180010de321e4a9">CV_CHARGE</a></div><div class="ttdef"><b>Definition:</b> charger.h:170</div></div>
<div class="ttc" id="charger_8h_html_a072b3046a3b425f96c26c3bb1a9376b8"><div class="ttname"><a href="charger_8h.html#a072b3046a3b425f96c26c3bb1a9376b8">FastVoltage</a></div><div class="ttdeci">uint32_t FastVoltage</div><div class="ttdef"><b>Definition:</b> charger.h:178</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cdeacad1f95421284c28d462180d85c320e9"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cdeacad1f95421284c28d462180d85c320e9">CC_CHARGE</a></div><div class="ttdef"><b>Definition:</b> charger.h:166</div></div>
<div class="ttc" id="charger_8h_html_af912b18af8de205312a5d27282e95cde"><div class="ttname"><a href="charger_8h.html#af912b18af8de205312a5d27282e95cde">ChargerState</a></div><div class="ttdeci">ChargerState</div><div class="ttdef"><b>Definition:</b> charger.h:142</div></div>
<div class="ttc" id="charger_8h_html_a83e89a22da06d138a4a9373955d02d34"><div class="ttname"><a href="charger_8h.html#a83e89a22da06d138a4a9373955d02d34">RawVoltage</a></div><div class="ttdeci">uint32_t RawVoltage</div><div class="ttdef"><b>Definition:</b> charger.h:178</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_bfccd401955b95cf8c75461437045ac0.html">inc</a></li><li class="navelem"><a class="el" href="charger_8h.html">charger.h</a></li>
    <li class="footer">Generated on Mon Jan 13 2014 08:36:57 for BatteryCharger by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
